//禁掉缩放
document.onmousewheel = function (evt) 
 {	try{
	  var e = evt || window.event;
     if(e.preventDefault && e.ctrlKey) e.preventDefault();
     if(e.ctrlKey) e.returnValue = false;
	 }catch(error){
	 window.event.returnValue = false;
	 }
 } 
 if (window.addEventListener) window.addEventListener('DOMMouseScroll', document.onmousewheel, false);


function change(option){
	var area = (typeof option.area=="undefined")?jQuery(""):option.area;				//鼠标经过停止自动播放的区域
	var box = (typeof option.box=="undefined")?jQuery(""):option.box; 					//包含项目的容器
	var btn = (typeof option.btn=="undefined")?jQuery(""):option.btn;					//包含焦点按钮的容器
	var leftBtn = (typeof option.leftBtn=="undefined")?jQuery(""):option.leftBtn;		//左按钮
	var rightBtn = (typeof option.rightBtn=="undefined")?jQuery(""):option.rightBtn;	//右按钮
	var waitTime = (typeof option.waitTime=="undefined")?8000:option.waitTime;			//切换间隔时间
	var fadeTime = (typeof option.fadeTime=="undefined")?"slow":option.fadeTime;		//淡入淡出时间
	var autoPlay = (typeof option.autoPlay=="undefined")?true:option.autoPlay;			//是否自动播放
	
	var listNum = box.find("li").length;
	box.find("li").hide();
	box.find("li:first").addClass("active").show();
	btn.find("li:first").addClass("selected");
    var img=box.find("li:first").find("img").attr("img");
    box.parent().siblings(".change_tit").find("img").attr("src",img);
	if(listNum <= 1){
		btn.hide();
		autoPlay = false;
	}
	
	//切换
	function changeItem(k){
		btn.find("li").removeClass("selected");
		btn.find("li").eq(k).addClass("selected");
		box.find("li").removeClass("active");
		box.find("li").eq(k).addClass("active");
		box.find("li").hide();
		box.find("li.active").fadeIn(fadeTime);
		var img = box.find("li.active").find("img").attr("img");
		box.parent().siblings(".change_tit").find("img").attr("src", img);
	}
	
	//点击左按钮
	leftBtn.click(function(){
		var e = box.find("li.active").index();
		if(e == 0){e = listNum;}
		e = e - 1;
		changeItem(e);
	});
	
	//点击右按钮
	rightBtn.click(function(){
		var e = box.find("li.active").index();
		if(e == listNum - 1){e = -1;}
		e = e + 1;
		changeItem(e);
	});
	
	//点击焦点按钮
	btn.find("li").click(function(){
		var e = jQuery(this).index();
		changeItem(e);
	});
	
	//自动播放
	function autoRun(){
		var e = box.find("li.active").index();
		if(e == listNum - 1){e = -1;}
		e = e + 1;
		changeItem(e);
	}
	
	if(autoPlay){    
        var intID = setInterval(autoRun,waitTime);                
        area.hover(function(){
            clearInterval(intID);
        },function(){
            intID = setInterval(autoRun,waitTime);
        });
    }
	
}
/*-------------------------------------------------------------------------------------------------------------------------------*/
$(function(){
	var slideDiv = $("#bannerImg");
	var imgWid = slideDiv.find("img").width();
	setWidth();
	function setWidth(){
		var screenWid = $(window).width();
		var hideWid = (screenWid - imgWid)/2;
		var hideWidSmall =  (980 - imgWid)/2;
		if(screenWid >= imgWid){
			slideDiv.css({"width":imgWid + "px","margin":"0 auto"});
		}else{
			if(screenWid > 980){
				slideDiv.css({"width":screenWid + "px","overflow":"hidden"});
				slideDiv.find("li").css({"width":screenWid + "px","overflow":"hidden"});
				slideDiv.find("img").css("margin-left",hideWid + "px");
			}else{
				slideDiv.css({"width":"980px","overflow":"hidden"});
				slideDiv.find("li").css({"width":"980px","overflow":"hidden"});
				slideDiv.find("img").css("margin-left",hideWidSmall + "px");
			}
		}
	}
	
	$(window).resize(function(){
		setWidth();
	});
	
});

//切换
$(function(){
	change({
		area : $("#bannerBox"),				//鼠标经过停止自动播放的区域
		box : $("#bannerImg"),					//包含项目的容器
		btn : $("#bannerBtn"),					//包含焦点按钮的容器
		leftBtn : $("#bannerBox a.leftBtn"),		//左按钮
		rightBtn : $("#bannerBox a.rightBtn"),		//右按钮
		waitTime : 8000,						//切换间隔时间
		fadeTime : 500,						//淡入淡出时间
		autoPlay : true							//是否自动播放
	});
});


/*综合*/
$(function(){
	$(".header_menu > ul > li").last().addClass("bg");
	$(".header_outmenu > ul > li").last().addClass("bg");
	/*首页banner小圆点移上去效果*/
	$(".btn li").hover(function(){
//		$(this).find("span").stop().animate({opacity:'1'},300);
//		},function(){
//			$(this).find("span").stop().animate({opacity:'0'},500);
//			});
	})
});
	
/*切换*/
$(document).ready(function(){
	changes = function(){
		var hei=$(".img_list").height();
		var wid=$(".img_list").width()+170;
		//$(".img_change").css({"height":hei+"px","width":wid+"px"});
		}
	changes();
	$(window).resize(function(){
		changes();
		});
$(function(){
	change({
		area : $(".img_change"),				//鼠标经过停止自动播放的区域
		box : $(".img_list"),					//包含项目的容器
		btn : $(".img_list"),					//包含焦点按钮的容器
		leftBtn : $(".img_change a.leftBtn"),		//左按钮
		rightBtn : $(".img_change a.rightBtn"),		//右按钮
		waitTime : 8000,						//切换间隔时间
		fadeTime : 500,						//淡入淡出时间
		autoPlay : false							//是否自动播放
	});
});
		});



/*------------------------------------------------------返回顶部----------------------------------------------------------------------------*/
$(function(){
	$(window).scroll(function(){		
		var pos = Math.max($("html").scrollTop(),$("body").scrollTop());
		if( pos > 100){
			$(".returnTop").show();
		}else{
			$(".returnTop").hide();
		}
	});
	$(".returnTop").click(function(){
		$("html").animate({scrollTop:0},1000);//火狐IE6789
		$("body").animate({scrollTop:0},1000);//谷歌	
	});
});
/*------------------------------------------------------返回顶部 - end----------------------------------------------------------------------*/






